package com.sgb.kjwl.viewmodel.self.publish;


import com.sgb.kjwl.AppConstant;
import com.sgb.link.entity.PublicTypeEntity;
import com.sgb.kjwl.repository.SelfRepertory;
import com.sgb.kjwl.view.ui.activity.self.publish.PublicPublishTypeActivity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MLog;

import java.util.List;

import io.reactivex.functions.Consumer;

public class MachinePublishTypeModel extends BaseViewModel {
    private PublicPublishTypeActivity activity;
    private SelfRepertory repertory;

    public MachinePublishTypeModel(PublicPublishTypeActivity activity, SelfRepertory repertory) {
        this.activity = activity;
        this.repertory = repertory;
    }

    //获取机械类型
    public void getMachineTypeModel() {
        DialogHelper.showProgressDialog(activity, null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        repertory.getMachineOutType()
                .subscribe(new Consumer<BaseEntity<List<PublicTypeEntity<List<PublicTypeEntity>>>>>() {
                    @Override
                    public void accept(BaseEntity<List<PublicTypeEntity<List<PublicTypeEntity>>>> listBaseEntity) throws Exception {
                        DialogHelper.dismissProgressDialog();
                        activity.getMachineTypeSucc(listBaseEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        DialogHelper.dismissProgressDialog();
                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
                    }
                });
    }

    //获取机械型号和属性
    /*public void getMachineDictModel() {
        repertory.getMachineDict("201904102758269", "201904101162338")
                .subscribe(new Consumer<BaseEntity<List<DictEntity>>>() {
                    @Override
                    public void accept(BaseEntity<List<DictEntity>> listBaseEntity) throws Exception {

                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
                    }
                });
    }*/
}
